package com.doumuxie.exception;

import com.doumuxie.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author liangliang
 * @version 1.0
 * @date 2019/5/28 11:17
 * @description GlobalExceptionHandler 全局异常处理
 **/
@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    /**
     * 捕获全局异常
     *
     * @param e 异常信息
     * @return 返回统一格式
     */
    @ExceptionHandler(Exception.class)
    public ResultUtil exceptionHandler(Exception e) {
        logger.error(e.getMessage());
        return ResultUtil.error("服务器繁忙!");
    }

}
